{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import cv2\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def nothing(x):\n",
    "    pass\n",
    "\n",
    "img = np.zeros((512,512,3),np.uint8)\n",
    "cv2.namedWindow('color')\n",
    "cv2.createTrackbar('R','color',0,255,nothing)\n",
    "cv2.createTrackbar('G','color',0,255,nothing)\n",
    "cv2.createTrackbar('B','color',0,255,nothing)\n",
    "switch='0:OFF\\n1:ON'\n",
    "cv2.createTrackbar(switch,'color',0,1,nothing)\n",
    "while True:\n",
    "    cv2.imshow('color',img)\n",
    "    k = cv2.waitKey(1)&0xFF\n",
    "    if k == ord('q'):\n",
    "        break\n",
    "    r = cv2.getTrackbarPos('R','color')\n",
    "    g = cv2.getTrackbarPos('G','color')\n",
    "    b = cv2.getTrackbarPos('B','color')\n",
    "    s = cv2.getTrackbarPos(switch,'color')\n",
    "    if s == 0:\n",
    "        img[:] = 0\n",
    "    else:\n",
    "        img[:] = [b,g,r]\n",
    "cv2.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
